package com.gbx.ximalayating.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;

import com.gbx.ximalayating.entity.RecommendOne;
import com.gbx.ximalayating.fragment.DiscoveryColumnsFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/9.
 */

public class DiscoveryColumnsAdapter extends FragmentPagerAdapter {
    private List<RecommendOne.DiscoveryColumns.ConEntity> list1;
    private List<RecommendOne.DiscoveryColumns.ConEntity> list2;
    private List<List<RecommendOne.DiscoveryColumns.ConEntity>> data;

    public DiscoveryColumnsAdapter(FragmentManager fm, List<RecommendOne.DiscoveryColumns.ConEntity> list) {
        super(fm);
        Log.e("1620", "dislist.size is "+list.get(0).getTitle());
        Log.e("1620", "dislist.size is "+list.get(0).getCoverPath());
        Log.e("1620", "dislist.size is "+list.size());
        list1 = new ArrayList<>();
        list2 = new ArrayList<>();
        data = new ArrayList<>();
        for (int i = 0; i <4 ; i++) {
            list1.add(list.get(i));
        }
        for (int i = 4; i <8 ; i++) {
            list2.add(list.get(i));
        }
        data.add(list1);
        data.add(list2);
    }

    @Override
    public Fragment getItem(int position) {
        return DiscoveryColumnsFragment.getInstance(data.get(position));
    }

    @Override
    public int getCount() {
        return data.size();
    }
}
